import sys
import json
from pymongo import MongoClient
import pymongo
from decimal import Decimal
city=sys.argv[1]
db_name=sys.argv[2]
client=MongoClient("182.92.96.120",3719)
db=client['admin']
db.authenticate('root', 'zhuge1116')
db=client[db_name]
borough_price_file="%s/borough_del" % city
def default(obj):
    if isinstance(obj, Decimal):
        return str(obj)
    raise TypeError
newitem={}
with open(borough_price_file, 'w') as f:
    for item in db['borough_del_name'].find():
        try:
            for name in item['borough_byname']:
                print name
                f.write(name)
                f.write("\n")
        except:
            pass

